package com.vitabuybuy.tv.ui.mine.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.library.common.base.BindRecycAdapter
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemActivityRewardsBinding
import com.vitabuybuy.tv.databinding.ItemAddress1Binding
import com.vitabuybuy.tv.dto.ActivityUserRecordDto

class ActivityRewardsAdapter :
    BindRecycAdapter<ItemActivityRewardsBinding, ActivityUserRecordDto>() {

    private var mAdapter: PointRewardsAdapter? = null

    override fun onBindViewHolder(
        mBinding: ItemActivityRewardsBinding,
        itemData: ActivityUserRecordDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mAdapter = PointRewardsAdapter(itemData.quantity)
        mAdapter?.setNewData(itemData.activity.activityNodeList)
        mBinding.lvActivityPoint.apply {
            adapter = mAdapter
            layoutManager = LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)
        }
        mBinding.tvAlready.text = itemData.activity.name + "  已完成数量：" + itemData.quantity
//        mBinding.tvAlready.text =
//            String.format(mContext.getString(R.string.activity_reward_hint), itemData.quantity)
        mBinding.tvRule.setOnClickListener {
            onClickRuteListener.invoke(itemData.activity.content)
        }
    }

    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_activity_rewards
    }

    lateinit var onClickRuteListener: (content: String) -> Unit
}
